module.exports = {
    // devServer: {
    //     open: true,
    //     host: 'localhost',
    //     port: 8080,
    //     https: false,
    //     hotOnly: false, 
    configureWebpack:{
        devServer: {
            
            open:true, 
            // mock数据
            before(app){
                //   app.get('',(req,res)=>{
                //         res.json({

                //         })

                //   })
                    // 注册接口
                    let userpoor=[
                        {username:"liudehua",password:"123456"},
                        {username:"adadd",password:"1213212313"}
                    ]
                    app.get("/api/register",(req,res)=>{
                       const {username,password}=req.query 
                     const userlength=userpoor.filter(v=>v.username==username).length
                     if(userlength>0){
                         res.json({
                             success:false,
                             message:"用户名已经存在"
                         })
                     }else{
                        res.json({
                            success:true,
                            message:"注册成功"
                        })
                     }

                    })
                    // 登录接口
                    let tokenkey='xdclass'
                    app.get('/api/login',(req,res)=>{
                        const {username,password}=req.query
                         if(username=="liudehua"&&password=="123456" || username=="adadd"&&password=="1213212313"){
                             res.json({
                                 code:0,
                                 message:"登陆成功",
                                 token:tokenkey+'-'+username+'-'+(new Date().getTime()+60*60*1000)
                             })
                         }else{
                            res.json({
                                  code:1,
                                  message:"账号密码错误"
                            })
                        }
                    })
                    // 轮播图接口
                    app.get("/api/banner",(req,res)=>{
                                     res.json({
                                   data:[
                                      {  
                                        image: '//m.360buyimg.com/mobilecms/s700x280_jfs/t1/115456/40/7331/100669/5ec3a9c6E3dcbadb7/46071c04455c0d5b.jpg!q70.jpg.dpg'
                                      },
                                      {
                                      image:'//imgcps.jd.com/ling4/7507183/55O35oSf6IKM6IKk/5ouS57ud5q-b5a2U57KX5aSn/p-5d91a4f642dd5b7c7d52cbde/32ca84bc/cr/s1125x690/q70.jpg'
                                    }
                                     ]

                                     })

                    })
                    // 分类接口
                    app.get("/api/lister",(req,res)=>{
                        res.json({
                      data:[
                         [
                             {
                           image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/125678/35/5947/4868/5efbf28cEbf04a25a/e2bcc411170524f0.png',
                           text:"京东超市"
                         },
                         {
                           image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/135931/4/3281/5598/5efbf2c0Edbdc82c7/ed9861b4ddfb9f30.png',
                           text:"我的电器"
                         },
                         {
                           image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/140012/8/1804/3641/5efbf318E38bd5dad/0db99d859ab16ce9.png',
                           text:"京东服饰"
                         },
                         {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/129215/21/5978/3618/5efbf344Ebec23ae8/59712d986b10bb0a.png',
                            text:"京东生鲜"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/116602/7/11200/3796/5efbf375Ebba41029/f07cc166f368fa05.png',
                            text:"京东到家"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/146390/3/1846/4909/5efbf39aEe5f5f797/300071558a9ab078.png',
                            text:"充值缴费"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/143365/25/1824/3716/5efbf3c0E5175e1fb/88f6227257a29f1d.png',
                            text:"9.9元拼"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/113589/24/11332/4897/5efbf3feE705d87db/e5c12d5e943266b9.png',
                            text:"领卷"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/131663/33/3380/3674/5efbf50fEf79cf314/af4b57d2383e605d.png',
                            text:"领金帖"
                          },
                          {
                            image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png',
                            text:"PLUS会员"
                          }
                         
                         ],
                         [
                            
                         {
                           image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/142596/7/1864/4759/5efbf5a9E60c62b8a/49cdd24cb2bfecf5.png',
                           text:"京东国际"
                         },
                         {
                           image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/125193/15/5993/3443/5efbf5dbEa3327124/a4282d5cb2879c8b.png',
                           text:"京东拍卖"
                         },
                         {
                           image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/133947/24/3428/4213/5efbf625E7e1b4e98/95fda84d8748f88d.png',
                           text:"唯品会"
                         },
                         {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/145692/9/1817/4493/5efbf652E61c4f3ec/722840c121d67fc6.png',
                            text:"玩3C"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/118396/30/11271/2692/5efbf680Eb3a3cf32/c3e85c4d99746400.png',
                            text:"沃尔玛"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/123571/19/6008/3747/5efbf6b2E03153a36/9ddc9036ba1c11a1.png',
                            text:"美妆管"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/115003/18/11199/3519/5efbf6eaEe59cb7f6/dab44230606cd112.png',
                            text:"京东旅行"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/142258/17/1800/4509/5efbf70aEb23e164e/61aaea8fe5221081.png',
                            text:"拍拍二手"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/116056/30/11288/4223/5efbf753Ee7cf2cd7/3977b5fe42b136e4.png',
                            text:"物流查询"
                          },
                          {
                            image: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/112559/35/11283/3523/5efbf774E285d108b/c0fa626df4979a21.png',
                            text:"全部"
                          }
                        ]
                         
                          
                      ]

                        })

       }),
        // 滚动分类接口
        app.get("/api/rollinglist",(req,res)=>{
            switch(req.query.type){
                case "0":
                    res.json({
                        data:[
                           {
                             image: '//img11.360buyimg.com/focus/s140x140_jfs/t1/117080/5/10502/18158/5ef0103eE416ae569/898a7ac882ba6c63.jpg',
                             label:"空调"
                           },
                           {
                             image: '//img10.360buyimg.com/focus/s140x140_jfs/t1/119891/13/5448/24096/5ef01048E096cfd33/260803efca5e8a73.jpg',
                             label:"冰箱"
                           },
                           {
                             image: '//img12.360buyimg.com/focus/s140x140_jfs/t1/131424/31/274/19042/5ecb3bc2E96ef8448/0188085e6fd6cd12.png',
                             label:"电脑"
                           },
                           {
                            image: '//img14.360buyimg.com/focus/s140x140_jfs/t27136/183/1628977274/31007/a6f7ed55/5be6ebd8Nb07ef492.png',
                            label:"手机"
                          },
                          {
                            image: '//img14.360buyimg.com/focus/s140x140_jfs/t1/114862/21/8081/13361/5ecb398fEc7c98869/4b4101d0acbf4ced.jpg',
                            label:"口罩"
                          },
                          {
                            image: '//img11.360buyimg.com/focus/s140x140_jfs/t1/113143/20/8135/9835/5ecb81ccE22407538/e9a80b7af28e83a6.jpg',
                            label:"数据线"
                          }
                        ]
              
                          });
                          break;
                          case "1":
                            res.json({
                                data:[
                                   {
                                     image: '//img30.360buyimg.com/focus/s140x140_jfs/t13411/188/926813276/3945/a4f47292/5a1692eeN105a64b4.png',
                                     label:"小米"
                                   },
                                   {
                                     image: '//img14.360buyimg.com/focus/s140x140_jfs/t11929/135/2372293765/1396/e103ec31/5a1692e2Nbea6e136.jpg',
                                     label:"华为"
                                   },
                                   {
                                     image: '//img10.360buyimg.com/focus/s140x140_jfs/t12178/348/911080073/4732/db0ad9c7/5a1692e2N6df7c609.jpg',
                                     label:"荣耀"
                                   }
                                ]
                      
                                  });
                                  break;   
                                  case "2":
                                    res.json({
                                        data:[
                                           {
                                             image: '//img13.360buyimg.com/focus/s140x140_jfs/t11071/195/2462134264/9117/cd0688bf/5a17ba79N18b9f3d4.png',
                                             label:"轻薄本"
                                           },
                                           {
                                             image: '//img30.360buyimg.com/focus/s140x140_jfs/t11155/36/2330310765/10690/eb6754c3/5a17ba96N49561fea.png',
                                             label:"游戏本"
                                           },
                                           {
                                             image: '//img20.360buyimg.com/focus/s140x140_jfs/t12679/262/982342141/7023/d05a11e5/5a17ba57Nf179b4e4.jpg',
                                             label:"显卡"
                                           }
                                        ]
                              
                                          });
                                          break;      
            }

})

            }
        }

    },

    css: {
      loaderOptions: {
        stylus: {
          'resolve url': true,
          'import': [
            './src/theme'
          ]
        }
      }
    },

    pluginOptions: {
      'cube-ui': {
        postCompile: true,
        theme: true
      }
    }
}
